<template>
  <!--股东信息  -->
  <div style="height:520px">
    <FormPanel
      ref="infoStock"
      :list="initForm"
      :cols="3"
      :formType="value.type"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //初始化数据
    init(data) {
      this.formValue = {};
      if (data.type === 'edit') {
        this.initForm.forEach(x => {
          x.initialValue = data.row[x.fieldName];
        });
      }
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'INPUT',
          label: '股东一',
          fieldName: 'stock1',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '资金',
          fieldName: 'money1',
          initialValue: '',
          unitRender: () => {
            return <span>万</span>
          }
        },
        {
          type: 'INPUT',
          label: '占比',
          fieldName: 'zhan1',
          initialValue: '',
          unitRender: () => {
            return <span>%</span>
          }
        },
        {
          type: 'INPUT',
          label: '股东二',
          fieldName: 'stock2',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '资金',
          fieldName: 'money2',
          initialValue: '',
          unitRender: () => {
            return <span>万</span>
          }
        },
        {
          type: 'INPUT',
          label: '占比',
          fieldName: 'zhan2',
          initialValue: '',
          unitRender: () => {
            return <span>%</span>
          }
         },
        {
          type: 'INPUT',
          label: '股东三',
          fieldName: 'stock3',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '资金',
          fieldName: 'money3',
          initialValue: '',
          unitRender: () => {
            return <span>万</span>
          }
        },
        {
          type: 'INPUT',
          label: '占比',
          fieldName: 'zhan3',
          initialValue: '',
          unitRender: () => {
            return <span>%</span>
          }
        },
        {
          type: 'INPUT',
          label: '其他',
          fieldName: 'other3',
          initialValue: ''
        },
        {
          type: 'INPUT',
          label: '资金',
          fieldName: 'money4',
          initialValue: '',
          unitRender: () => {
            return <span>万</span>
          }
        },
        {
          type: 'INPUT',
          label: '占比',
          fieldName: 'zhan4',
          initialValue: '',
          unitRender: () => {
            return <span>%</span>
          }
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
    }
  }
};
</script>